package p270jp.pxv.android.novelText.presentation.flux;

import androidx.lifecycle.AbstractC0720j0;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import java.util.List;
import java.util.Objects;
import p189gn.AbstractC3446l;
import p216hn.Lambda;
import p270jp.pxv.android.novelText.domain.model.Chapter;
import p325m0.MutabilityOwnership;
import p445qf.ReadOnlySingleLiveEvent;
import p445qf.SingleLiveEvent;
import p449qk.Marker;
import p467rd.subscribers;
import p493sf.AbstractC6047g;
import p493sf.FluxUtils;
import p524tk.NovelTextAction;
import p524tk.NovelTextEvent;
import p603wm.Tuples;
import p603wm.Unit;
import p629xm.C7192p;
import p671zc.CompositeDisposable;

/* compiled from: NovelTextStore.kt */
/* renamed from: jp.pxv.android.novelText.presentation.flux.NovelTextStore */
/* loaded from: classes2.dex */
public final class NovelTextStore extends AbstractC0720j0 {

    /* renamed from: c */
    public final CompositeDisposable f19272c;

    /* renamed from: d */
    public final SingleLiveEvent<NovelTextEvent> f19273d;

    /* renamed from: e */
    public MutableLiveData<Tuples<Integer, Integer>> f19274e;

    /* renamed from: g */
    public boolean f19276g;

    /* renamed from: h */
    public Integer f19277h;

    /* renamed from: i */
    public final ReadOnlySingleLiveEvent<NovelTextEvent> f19278i;

    /* renamed from: j */
    public final LiveData<Tuples<Integer, Integer>> f19279j;

    /* renamed from: l */
    public String f19281l;

    /* renamed from: m */
    public String f19282m;

    /* renamed from: f */
    public int f19275f = 1;

    /* renamed from: k */
    public List<Chapter> f19280k = C7192p.f30161a;

    /* compiled from: NovelTextStore.kt */
    /* renamed from: jp.pxv.android.novelText.presentation.flux.NovelTextStore$a */
    /* loaded from: classes2.dex */
    public static final class C4307a extends Lambda implements AbstractC3446l<FluxUtils, Unit> {
        public C4307a() {
            super(1);
        }

        @Override // p189gn.AbstractC3446l
        public Unit invoke(FluxUtils aVar) {
            NovelTextEvent cVar;
            int intValue;
            FluxUtils aVar2 = aVar;
            MutabilityOwnership.m3745m(aVar2, "it");
            if (aVar2 instanceof NovelTextAction.C6278n) {
                NovelTextStore novelTextStore = NovelTextStore.this;
                novelTextStore.f19276g = false;
                NovelTextAction.C6278n nVar = (NovelTextAction.C6278n) aVar2;
                novelTextStore.f19273d.m11032n(new NovelTextEvent.C6296p(nVar.f26852a, nVar.f26853b, nVar.f26854c));
            } else if (aVar2 instanceof NovelTextAction.C6277m) {
                Objects.requireNonNull(NovelTextStore.this);
                NovelTextStore.this.f19273d.m11032n(new NovelTextEvent.C6292l(((NovelTextAction.C6277m) aVar2).f26851a));
            } else if (aVar2 instanceof NovelTextAction.C6275k) {
                Objects.requireNonNull(NovelTextStore.this);
                NovelTextStore.this.f19273d.m11032n(new NovelTextEvent.C6290j(((NovelTextAction.C6275k) aVar2).f26849a));
            } else if (aVar2 instanceof NovelTextAction.C6279o) {
                NovelTextStore.this.f19273d.m11032n(NovelTextEvent.C6297q.f26886a);
            } else if (aVar2 instanceof NovelTextAction.C6276l) {
                NovelTextStore.this.f19273d.m11032n(NovelTextEvent.C6291k.f26878a);
            } else if (aVar2 instanceof NovelTextAction.C6269e) {
                NovelTextStore novelTextStore2 = NovelTextStore.this;
                if (!novelTextStore2.f19276g) {
                    novelTextStore2.f19273d.m11032n(NovelTextEvent.C6286f.f26873a);
                }
            } else if (aVar2 instanceof NovelTextAction.C6270f) {
                NovelTextStore.this.f19276g = true;
            } else if (aVar2 instanceof NovelTextAction.C6272h) {
                NovelTextAction.C6272h hVar = (NovelTextAction.C6272h) aVar2;
                NovelTextStore.this.f19275f = hVar.f26846a.getTotalPageCount();
                NovelTextStore.this.f19280k = hVar.f26846a.getChapters();
                NovelTextStore novelTextStore3 = NovelTextStore.this;
                Marker marker = hVar.f26846a.getMarker();
                novelTextStore3.f19277h = marker == null ? null : marker.getPage();
                NovelTextStore novelTextStore4 = NovelTextStore.this;
                String str = novelTextStore4.f19282m;
                if (str == null) {
                    Integer num = novelTextStore4.f19277h;
                    if (num != null && (intValue = num.intValue()) > 1) {
                        novelTextStore4.f19273d.m11032n(new NovelTextEvent.C6295o(intValue));
                    } else {
                        novelTextStore4.f19273d.m11032n(NovelTextEvent.C6293m.f26880a);
                    }
                } else {
                    novelTextStore4.f19273d.m11032n(new NovelTextEvent.C6294n(str));
                }
            } else if (aVar2 instanceof NovelTextAction.C6273i) {
                NovelTextAction.C6273i iVar = (NovelTextAction.C6273i) aVar2;
                NovelTextStore.this.f19281l = iVar.f26847a.getState();
                NovelTextStore.this.f19274e.m11032n(new Tuples<>(Integer.valueOf(iVar.f26847a.getPage()), Integer.valueOf(NovelTextStore.this.f19275f)));
                NovelTextStore.this.f19273d.m11032n(NovelTextEvent.C6298r.f26887a);
            } else if (aVar2 instanceof NovelTextAction.C6280p) {
                SingleLiveEvent<NovelTextEvent> eVar = NovelTextStore.this.f19273d;
                NovelTextAction.C6280p pVar = (NovelTextAction.C6280p) aVar2;
                if (pVar.f26856a.getShowUi() == null) {
                    cVar = NovelTextEvent.C6299s.f26888a;
                } else if (pVar.f26856a.getShowUi().booleanValue()) {
                    cVar = NovelTextEvent.C6289i.f26876a;
                } else {
                    cVar = NovelTextEvent.C6285e.f26872a;
                }
                eVar.m11032n(cVar);
            } else if (aVar2 instanceof NovelTextAction.C6271g) {
                NovelTextStore.this.f19273d.m11032n(new NovelTextEvent.C6287g(((NovelTextAction.C6271g) aVar2).f26845a));
            } else if (aVar2 instanceof NovelTextAction.C6274j) {
                NovelTextStore.this.f19273d.m11032n(new NovelTextEvent.C6288h(((NovelTextAction.C6274j) aVar2).f26848a.getId()));
            } else if (aVar2 instanceof NovelTextAction.C6267c) {
                NovelTextStore.this.f19273d.m11032n(new NovelTextEvent.C6283c(((NovelTextAction.C6267c) aVar2).f26841a));
            } else if (aVar2 instanceof NovelTextAction.C6268d) {
                NovelTextStore.this.f19273d.m11032n(new NovelTextEvent.C6284d(((NovelTextAction.C6268d) aVar2).f26842a));
            } else if (aVar2 instanceof NovelTextAction.C6266b) {
                NovelTextStore.this.f19273d.m11032n(new NovelTextEvent.C6282b(((NovelTextAction.C6266b) aVar2).f26840a));
            } else if (aVar2 instanceof NovelTextAction.C6265a) {
                NovelTextAction.C6265a aVar3 = (NovelTextAction.C6265a) aVar2;
                NovelTextStore.this.f19273d.m11032n(new NovelTextEvent.C6281a(aVar3.f26838a, aVar3.f26839b));
            }
            return Unit.f29503a;
        }
    }

    public NovelTextStore(AbstractC6047g gVar) {
        MutabilityOwnership.m3745m(gVar, "readOnlyDispatcher");
        CompositeDisposable aVar = new CompositeDisposable();
        this.f19272c = aVar;
        SingleLiveEvent<NovelTextEvent> eVar = new SingleLiveEvent<>();
        this.f19273d = eVar;
        MutableLiveData<Tuples<Integer, Integer>> xVar = new MutableLiveData<>();
        this.f19274e = xVar;
        this.f19278i = eVar;
        this.f19279j = xVar;
        aVar.mo82c(subscribers.m2589g(gVar.mo2435a(), null, null, new C4307a(), 3));
    }

    @Override // androidx.lifecycle.AbstractC0720j0
    /* renamed from: b */
    public void mo315b() {
        this.f19272c.m80f();
    }
}
